package com.cb.admin.controllers;

import java.util.Map;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cb.admin.service.IApiService;

@Controller
@RequestMapping("/api")
public class ApiController {

	private static Logger logger = Logger.getLogger(ApiController.class.getName());
	
	@Autowired
	private IApiService apiService;
	
	@RequestMapping(path = "/getXsList", method = RequestMethod.GET)
	@ResponseBody
	public String getXsList(@RequestParam("createTime") String createTime,
			@RequestParam("start") String start,@RequestParam("length") String length) {
		//当前页  
		JSONObject jo = new JSONObject();
		Map rep = apiService.queryXS(createTime,start,length);
		jo.put("rows", rep.get("lis"));
		jo.put("total", rep.get("size"));
		return jo.toString();
	}
	
	@RequestMapping(path = "/getWebGjList", method = RequestMethod.GET)
	@ResponseBody
	public String getWebGjList(@RequestParam("createTime") String createTime,
			@RequestParam("start") String start,@RequestParam("length") String length) {
		//当前页  
		JSONObject jo = new JSONObject();
		Map rep = apiService.queryWebGJ(createTime,start,length);
		jo.put("rows", rep.get("lis"));
		jo.put("total", rep.get("size"));
		return jo.toString();
	}
	
	@RequestMapping(path = "/getAppGjList", method = RequestMethod.GET)
	@ResponseBody
	public String getAppGjList(@RequestParam("createTime") String createTime,
			@RequestParam("start") String start,@RequestParam("length") String length) {
		//当前页  
		JSONObject jo = new JSONObject();
		Map rep = apiService.queryAppGJ(createTime,start,length);
		jo.put("rows", rep.get("lis"));
		jo.put("total", rep.get("size"));
		return jo.toString();
	}
}
